﻿using System.Windows.Controls;

namespace Songhay.Silverlight.BiggestBox.IndexPart.Views.UserControls
{
    /// <summary>
    /// Master-Detail Sample User Control
    /// </summary>
    public partial class MasterDetailSample : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MasterDetailSample"/> class.
        /// </summary>
        public MasterDetailSample()
        {
            InitializeComponent();

            this.DataGridOne.SelectionChanged += (s, args) =>
            {
                if(this.DataGridOne.SelectedIndex == this._previousSelectedIndex) return;
                this._previousSelectedIndex = this.DataGridOne.SelectedIndex;
                this.DataGridOne.ScrollIntoView(this.DataGridOne.SelectedItem, this.DataGridOne.Columns[0]);
            };
        }

        int _previousSelectedIndex;
    }
}
